home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
doom
/
turric03.zip
/
TURRIC03.ZIP
/
PROGS
/
TRACBEAM.QC
< prev
next >
Wrap
Text File
|
1997-01-09
|
6KB
|
219 lines
/*
==============================================================================
TRACTOR BEAM
==============================================================================
This is based on the tracbeam patch by Jonathan Avraham aka Procedure aka
Shambler, procedure@hotmail.com, but has been almost completely
reprogrammed by Turrican.
*/
void() TracbeamThink =
{
local vector newpos, checkpoint;
local float dist, min_dist;
if(self.owner.tracbeam_time <= time)
{
self.owner.tracbeam_status = TRACBEAM_OFF;
self.victim.nextthink = time;
// Force released victims to fall.
// self.victim.velocity = '0 0 -50';
remove(self);
return;
}
self.victim.nextthink = time + 0.3;
// Find point to move victim to.
makevectors(self.owner.v_angle);
newpos = self.owner.origin + '0 0 16' + (v_forward * 20) + (v_forward * self.tracbeam_length);
// newpos = self.owner.origin + (v_forward * 20) + (v_forward * self.tracbeam_length);
// Check if new position is possible. If not don't do the move.
// Check if move will bring entities too close together.
min_dist = vlen(self.owner.maxs) + vlen(self.victim.maxs);
dist = vlen(self.owner.origin - self.victim.origin);
if (dist <= min_dist)
{
// Make warning sound.
sound (self, CHAN_ITEM, "weapons/beep1.wav", 1, ATTN_NORM);
self.nextthink = 0.1;
return;
}
// Check if each extreme of the victim's bounding box is visible. 8 points.
// 1
checkpoint = newpos + self.victim.maxs;
traceline(self.owner.origin, checkpoint, TRUE, self.victim);
if(trace_fraction == 1)
{
// 2
checkpoint = newpos +
'1 0 0' * self.victim.maxs_x +
'0 1 0' * self.victim.mins_y +
'0 0 1' * self.victim.maxs_z;
traceline(self.owner.origin, checkpoint, TRUE, self.victim);
if(trace_fraction == 1)
{
// 3
checkpoint = newpos +
'1 0 0' * self.victim.maxs_x +
'0 1 0' * self.victim.maxs_y +
'0 0 1' * self.victim.mins_z;
traceline(self.owner.origin, checkpoint, TRUE, self.victim);
if(trace_fraction == 1)
{
// 4
checkpoint = newpos +
'1 0 0' * self.victim.maxs_x +
'0 1 0' * self.victim.mins_y +
'0 0 1' * self.victim.mins_z;
traceline(self.owner.origin, checkpoint, TRUE, self.victim);
if(trace_fraction == 1)
{
// 5
checkpoint = newpos +
'1 0 0' * self.victim.mins_x +
'0 1 0' * self.victim.maxs_y +
'0 0 1' * self.victim.maxs_z;
traceline(self.owner.origin, checkpoint, TRUE, self.victim);
if(trace_fraction == 1)
{
// 6
checkpoint = newpos +
'1 0 0' * self.victim.mins_x +
'0 1 0' * self.victim.mins_y +
'0 0 1' * self.victim.maxs_z;
traceline(self.owner.origin, checkpoint, TRUE, self.victim);
if(trace_fraction == 1)
{
// 7
checkpoint = newpos +
'1 0 0' * self.victim.mins_x +
'0 1 0' * self.victim.maxs_y +
'0 0 1' * self.victim.mins_z;
traceline(self.owner.origin, checkpoint, TRUE, self.victim);
if(trace_fraction == 1)
{
// 8
checkpoint = newpos + self.victim.mins;
traceline(self.owner.origin, checkpoint, TRUE, self.victim);
if(trace_fraction == 1)
{
// Move victim.
setorigin(self, newpos);
setorigin(self.victim, newpos);
}
}
}
}
}
}
}
}
// Rotate victim with beam.
// self.angles = vectoangles(v_forward);
// self.victim.angles = vectoangles(v_forward);
self.nextthink = 0.1;
};
void() W_FireTracbeam =
{
local vector org;
local entity tracbeam_ent;
if (self.ammo_cells < 1)
{
self.weapon = W_BestWeapon ();
W_SetCurrentAmmo ();
return;
}
// explode if under water
if (self.waterlevel > 1)
{
T_RadiusDamage (self, self, 35*self.ammo_cells, world);
self.ammo_cells = 0;
W_SetCurrentAmmo ();
return;
}
if (self.t_width < time)
{
sound (self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
self.t_width = time + 0.6;
}
self.punchangle_x = -2;
self.currentammo = self.ammo_cells = self.ammo_cells - 1;
org = self.origin + '0 0 16';
// Make the beam stop at the victim entity.
if(self.tracbeam_status == TRACBEAM_ON)
{
traceline (org, org + v_forward * self.tracbeam_length, TRUE, self);
}
else
{
traceline (org, org + v_forward * TRACBEAM_LEN, TRUE, self);
}
WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
WriteEntity (MSG_BROADCAST, self);
WriteCoord (MSG_BROADCAST, org_x);
WriteCoord (MSG_BROADCAST, org_y);
WriteCoord (MSG_BROADCAST, org_z);
WriteCoord (MSG_BROADCAST, trace_endpos_x);
WriteCoord (MSG_BROADCAST, trace_endpos_y);
WriteCoord (MSG_BROADCAST, trace_endpos_z);
traceline (org, org + v_forward * TRACBEAM_LEN, FALSE, self);
if(self.tracbeam_status == TRACBEAM_ON)
{
// Extend the lifespan of the tractorbeam entity.
self.tracbeam_time = time + 0.3;
}
else if(trace_ent.takedamage &&
trace_ent.movetype != MOVETYPE_NONE &&
trace_ent.classname != "flame1" &&
trace_ent.classname != "flame2" &&
trace_ent.classname != "flamer_bubble" &&
trace_ent.classname != "bubble" &&
trace_ent.classname != "trigger_multiple" &&
trace_ent.classname != "door")
{
// Create the tracbeam entity.
self.tracbeam_status = TRACBEAM_ON;
self.tracbeam_time = time + 0.3;
self.tracbeam_length = TRACBEAM_LEN * trace_fraction;
tracbeam_ent = spawn();
tracbeam_ent.solid = SOLID_NOT;
setsize(tracbeam_ent, VEC_ORIGIN, VEC_ORIGIN );
setorigin(tracbeam_ent, trace_ent.origin );
tracbeam_ent.owner = self;
tracbeam_ent.victim = trace_ent;
tracbeam_ent.tracbeam_length = TRACBEAM_LEN * trace_fraction;
tracbeam_ent.think = TracbeamThink;
tracbeam_ent.nextthink = 0.1;
// trace_ent.movetype = MOVETYPE_TOSS; causes a bug with items that are not meant to move like barrels.
}
};